package mytest.wd3;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import pojo.Import;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Stream {

    public static void main(String[] args) {
        ArrayList<Import> importList = new ArrayList<>();
        importList.add(new Import(1, "zhangjiali", "zhongguo", "1", "2024-10-20", "zhangjiali2"));
        importList.add(new Import(2, "zhangjiali", "zhongguo", "2", "2024-10-20", "zhangjiali2"));
        importList.add(new Import(3, "zhuxinmeng", "zhongguo", "1", "2024-10-22", "zhuxinmeng"));
        importList.add(new Import(4, "zhuxinmeng2", "zhongguo", "2", "2024-10-12", "zhuxinmeng2"));
        importList.add(new Import(5, "xucuncun", "zhongguo", "1", "2024-01-20", "xucuncun"));

        Map<String, List<Import>> collect = importList.stream().collect(Collectors.groupingBy(Import::getUserName));
       collect.forEach((userName, imports) -> {
           System.out.println("name: " + userName);
           imports.forEach(System.out::println);
       });

    }

}
